<!DOCTYPE html>
<html>
	<head>
		<meta charset="UTF-8">
		<title></title>
		<script src="js/lib/angular.min.js"></script>	
		<link rel="stylesheet" href="css/lib/bootstrap.min.css" />
		<link rel="stylesheet" href="js/themes/default/easyui.css" />
		<script src="js/lib/jquery-1.11.0.js"></script>
		<script src="js/lib/bootstrap.min.js"></script>		
		<script src="js/base.js" type="text/javascript" charset="utf-8"></script>
	</head>
	<style>
		body{
			font-size:12px;
		}
		input{
			width:280px;
		}
		span{
			width:20px;color:red;display:inline-block;text-align:left;
		}
		#sho{
			width:300px;
			height:50px;
			background:#d9534f;
			opacity:0.8;
			border-radius:8px;
			color:#fff;
			text-align: left;
			font-size:30px;
			position: absolute;
			top:0px;
			left:550px;
			display:none;
		}
	</style>
	<body ng-app="myApp" ng-controller="customersCtrl">
		<div class="">
			<div id="sho"></div>
		<!--第三个查询请求-->
		<div style="padding:15px 5px 0px 5px;border:3px solid #ccc;margin-bottom:15px">
			<table class="table table-hover" style="width:50%">				
					<tr>
						<th style="font-size:30px;" colspan="10">刷卡费率</th>
					</tr>
					<tr style="font-size:16px;font-weight:600;color:#666">
						<td class="text-left">通道名称</td>
						<td class="text-left">到账方式</td>
						<td class="text-left">单笔限额</td>
						<td class="text-left">当天限额</td>
						<td class="text-left">刷卡费率</td>
						<!-- <td class="text-left">结束时间</td> -->
					</tr>
					<tr ng-repeat="item in items2" ng-show="item.status == 1" style="font-family:'微软雅黑'">
						<!-- <td class="text-left">{{$index+1}}</td> -->
						<!-- <td class="text-left">{{item.id}}</td> -->
						<td class="text-left"><img style="width:20px;margin-right:20px;" src="{{item.log}}" alt="">{{item.name}}</td>
						<td class="text-left">{{item.channelParams}}</td>
						<td class="text-left">{{item.singleMinLimit}}元~{{item.singleMaxLimit}}元</td>
						<!-- <td class="text-left">{{item.singleMaxLimit}}元</td> -->
						<td class="text-left">{{item.everyDayMaxLimit}}元</td>
						<td  class="text-left" contenteditable="true">
												{{(item.rate*100).toFixed(2)}}%
							<!-- <input type="text" class="form-control" ng-model="item.rate" style="width:80px;margin:0 auto;"> -->
							</td>
						<!-- <td class="text-left"><button class="btn btn-default" ng-click="add(item)">修改费率</button></td> -->
						<!-- <td class="text-left">{{item.createTime}}</td> -->
					</tr>
					<tr>
						<td colspan="10" id="show02" class="text-left" style="display:none;">
						</td>
					</tr>				
			</table>		
		</div>
		</div>
	</body>
<!-- 	<script>		
	$(function(){
		var userid = sessionStorage.getItem(key=13); 
		$('#f1').val(userid);
		$('#f2').change(function(){
			var f1 = $("#f1").val();
			var f2 = $('#f2').val();
			console.log($("#f1").val())
			console.log($("#f2").val())
			$.ajax({
				url:window.baseUrl+"user/channel/rate/query/userid",
				type:"POST",
				dataType:"json",
				data:{
					user_id:f1,
					channel_id:f2,
				},
				success:function(data){
					console.log("开始远程调用...")
					console.log(data.result)
					$('#f3').val(data.result.rate)
					$('#f4').html(data.result.withdrawFee+"元")
				},
				error:function(){
					console.log("调用失败！");
					$('#show').hide();
					$('#show01').show().html("暂无数据");
				}
			})				
		});
		/*修改用户的通道费率:*/
            $('#f3').on('keyup',function(){
                var v = parseInt($('#f3').val()*10000);
                console.log(v);
                if(v>52){
                    $('#f3').val(0.0052)
			}
            });
		$('#f3').on('blur',function(){
			var v= $('#f3').val();
			if(v<0.0035){
			    alert('您的费率设置有误！请认真核对')
			    $('#f3').val(0.0035)
			}
		});

		$("#query1").click(function(){
			var f1 = $('#f1').val();
			var f2 = $('#f2').val();
			var f3 = $('#f3').val();
			console.log(f1);
			console.log(f2);
			console.log(f3);
			$.ajax({
				url:window.baseUrl+"user/channel/rate/update/userid",
				type:"POST",
				dataType:"json",
				data:{
					user_id:f1,
					channel_id:f2,
					rate:f3
				},
				success:function(data){
					console.log("开始远程调用...");
					console.log(data.result);
					var msg = data.result;
					if(data.result == null){
						$('#show').hide();
						$("#show01").show().html("暂无数据...")							
					}else{
						alert('成功设置费率为'+msg.rate);
						window.location.href = "zy03.html";
						$('#show01').hide();
						$('#show').show();
						$('#show1').html(msg.userId);
						$('#show2').html(msg.brandId);
						$('#show3').html(msg.channelId);
						if(msg.extraFee==null){
							$('#show4').html("-")
						}else{
							$('#show4').html(msg.extraFee)
						};							
						$('#show5').html("￥"+msg.withdrawFee);
						$('#show6').html(msg.rate+"%");
						$('#show7').html(msg.createTime);
					}											
				},
				error:function(){
					console.log("调用失败！");
					$('#show').hide();
					$('#show01').show().html("暂无数据");
				}
			})
		})
	})
</script> -->
	<script>
		var app = angular.module('myApp', []);
		/*自定义过滤器   1*/
				app.filter('modify0',function(){
					return function(input,param){
						if(param == "WEIXIN_QRCODE"){
							return param = "微信支付"
						}
						
					}
				});

	        app.controller('customersCtrl', function($scope, $http ){
	        	var userid = sessionStorage.getItem(key=4); 
				$('#f1').val(userid);
				/*根据用户编号展示所有平台信息和费率*/
				$http({
					method: 'POST',
					params: {user_id:userid},
					url: window.baseUrl+'user/channel/query/all/brandid'
				}).then(function successCallback(data){
						console.log("请求数据成功...");
						console.log(data.data.result);
						$scope.items2 = data.data.result
				}, function errorCallback(data) {
						console.log("请求数据失败...");
				     	console.log(data)
				});
				/*修改用户刷卡费率*/
				$scope.add = function(item){                   
				    console.log(item);
                    var userid = sessionStorage.getItem(key=13);
					var id = item.id;
					var rate = item.rate;
					console.log(userid);
				    console.log(id);
				    console.log(rate);
                    $http({
                        method: 'POST',
                        params: {
                            user_id:userid,
                            channel_id:id,
                            rate:rate
                        },
                        url: window.baseUrl+'user/channel/rate/update/userid'
                    }).then(function successCallback(data){
                        console.log("修改数据成功...");
                        console.log(data.data.result);
                        if(data.data.resp_code == 000000)
                        alert("成功设置【"+item.name+item.channelParams+"】通道刷卡费率为"+item.rate);
						if(data.data.resp_code == 999999)
						alert(data.data.resp_message);	

                    }, function errorCallback(data) {
                        console.log("修改数据失败...");
                        console.log(data)
                    })
                }
			});
	</script>
</html>




